<?php
defined('IN_PHPCMS') or exit('No permission resources.');
//模型缓存路径
define('CACHE_MODEL_PATH',CACHE_PATH.'caches_model'.DIRECTORY_SEPARATOR.'caches_data'.DIRECTORY_SEPARATOR);
pc_base::load_app_func('util','content');
pc_base::load_sys_class('form', '', 0);
class user {
	private $db;
	private $comapny_db;
	private $buy_product_db; 
	function __construct() {
		$this->db = pc_base::load_model('content_model');
	}
	//首页
	public function init() {
		
		if(isset($_GET['siteid'])) {
			$siteid = intval($_GET['siteid']);
		} else {
			$siteid = 1;
		}
		$siteid = $GLOBALS['siteid'] = max($siteid,1);
		//SEO
		$SEO = seo($siteid);
		$sitelist  = getcache('sitelist','commons');
		$default_style = $sitelist[$siteid]['default_style'];
		$CATEGORYS = getcache('category_content_'.$siteid,'commons');
		include template('content','index',$default_style);
	}
	//公司企业首页
	function company(){
		$SEO['title'] = '装饰公司';
		$cityid  = $_SESSION['cityid'];
		
	
		include template('company','company');
	}
	//设计师首页
	function designer(){
		$SEO['title'] = '装饰设计师';
		include template('designer','designer');
	}
	//单个公司首页
	function company_index(){
		$companyid = intval($_GET['companyid']);
		if($companyid<1) {return ;}
		$this->comapny_db = pc_base::load_model('company_model');
		$data = $this->comapny_db->get_one('companyid='.$companyid);
		//print_r($data);
		include template('company','company_index');
	}
//	function signed
	//发布求购
	function buy_product(){
		$SEO['title'] = '建材求购';
		$phpcms_auth = param::get_cookie('auth');
		$auth_key = md5(pc_base::load_config('system', 'auth_key').str_replace('7.0' ,'8.0',$_SERVER['HTTP_USER_AGENT']));
		list($userid, $password)= explode("\t", sys_auth($phpcms_auth, 'DECODE', $auth_key));
		if($userid!=''){
			$this->userdb = pc_base::load_model('member_model');
			$memberinfo = $this->userdb->get_one(array('userid'=>$userid));
			if($memberinfo['typeid']==1){
				$sendsure = 1;
			}else{
				$sendsure = 0;
			}
		}else{
			$sendsure = 0;
		}
		
		include template('company','buy_product');
	}
	//求购详细页
	function buy_product_dt(){
		include template('company','buy_product_dt');
	}
	//装饰学堂首页
	function school(){
		$this->buy_product_db = pc_base::load_model('buy_product_model');

		include template('content','school');
	}
	function publish_zhaobiao(){
		$phpcms_auth = param::get_cookie('auth');
		$auth_key = md5(pc_base::load_config('system', 'auth_key').str_replace('7.0' ,'8.0',$_SERVER['HTTP_USER_AGENT']));
		list($userid, $password)= explode("\t", sys_auth($phpcms_auth, 'DECODE', $auth_key));
		if($userid!=''){
			$this->userdb = pc_base::load_model('member_model');
			$memberinfo = $this->userdb->get_one(array('userid'=>$userid));
			if($memberinfo['typeid']==1){
				$sendsure = 1;
			}else{
				$sendsure = 0;
			}
		}else{
			$sendsure = 0;
		}
		include template('content','publish_zhaobiao');
	}
	private function _session_start() {
		$session_storage = 'session_'.pc_base::load_config('system','session_storage');
		pc_base::load_sys_class($session_storage);
	}

}
?>